﻿using PlayingCards.Model.Entity;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace PlayingCards.Repository
{
    public class PlayingCardsContext 
    {
        public PlayingCardsContext()
        {
			Db = new SqlSugarClient(new ConnectionConfig
			{


			});
			
        }
		public SqlSugarClient Db;

        public void Show()
        {
			try
			{
				SqlSugarClient sqlSugarClient = new SqlSugarClient(new ConnectionConfig
				{
					DbType = DbType.SqlServer, // 要连接的数据库类型
					ConnectionString = @"Server=LAPTOP-MUE0IKB9;database=PlayingCards;uid=sa;pwd=sa;Integrated Security=False;", // 数据库连接字符串
					IsAutoCloseConnection = true,
				});
				sqlSugarClient.DbMaintenance.CreateDatabase(); // 创建数据库
				// 创建表
				sqlSugarClient.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Room));
				sqlSugarClient.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Card));
				sqlSugarClient.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(Player));
				sqlSugarClient.CodeFirst.SetStringDefaultLength(200).InitTables(typeof(PlayerList));
				
            }
			catch (Exception)
			{

				throw;
			}
        }
    }
}
